<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form">
    <input name="id" id="id" type="hidden"/>
    <input name="photoUrl" id="photoUrl" type="hidden"/>
    <br/>
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">分享页面规则</label>
        <div class="layui-input-inline">
            <textarea name="shareRule" style="width: 450px;height: 150px" id="shareRule"
                      class="layui-textarea"></textarea>
        </div>
    </div>
    <hr class="layui-bg-gray">
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">提现页面规则</label>
        <div class="layui-input-inline">
            <textarea name="withdrawRule" style="width: 450px;height: 150px" id="withdrawRule"
                      class="layui-textarea"></textarea>
        </div>
    </div>
    <hr class="layui-bg-gray">
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">发票提醒文案</label>
        <div class="layui-input-inline">
            <textarea name="invoiceRule" style="width: 450px;height: 150px" id="invoiceRule"
                      class="layui-textarea"></textarea>
        </div>
    </div>
    <hr class="layui-bg-gray">
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">加入会员页面文案</label>
        <div class="layui-input-inline">
            <textarea name="joinVipRule" style="width: 450px;height: 250px" id="joinVipRule"
                      class="layui-textarea"></textarea>
        </div>
    </div>
    <button class="layui-btn" id="formSubmit" lay-submit="" lay-filter="formSubmit" style="display: none">立即提交</button>
</form>
<script th:replace="/common/inc::incJs"></script>
<style type="text/css">
    .w-e-text-container {
        height: 500px !important;
        width: 700px /*!important是重点，因为原div是行内样式设置的高度300px*/
    }
</style>
<script>
    var form = layui.form;
    var successCallback;
    var id = getQueryString("id");
    $("#id").val(id);
    //监听提交
    form.on('submit(formSubmit)', function (data) {
        if (id != "") {
            $.post('/backend/security/copywritingRules/update', data.field, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                }
                else {
                    layer.msg('操作成功');
                    parent.layui.table.reload("grid");
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            });
        }
        else {
            $.post('/backend/security/copywritingRules/add', data.field, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                }
                else {
                    layer.msg('操作成功');
                    parent.layui.table.reload("grid");
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            });
        }
        return false;
    });


    var formSubmit = function (callback) {
        successCallback = callback;
        $("#formSubmit").click();
    }


    $(function () {
        if (id != "") {
            $.post('/backend/security/copywritingRules/getById', {id: id}, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                }
                else {
                    $("form").loadData(res.body);
                }
            });
        }
    })
</script>
</body>
</html>
